
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 0073
 * @Author : WangRuoyu 
 * @Date : 2023/9/7 14:49
 */

#include "iostream"
#include "vector"

using namespace std;

class Solution {
public:
    void setZeroes(vector<vector<int>> &matrix) {
        bool row[matrix.size()];
        bool column[matrix[0].size()];
        for (int i = 0; i < matrix.size(); ++i) {
            row[i] = false;
        }
        for (int i = 0; i < matrix[0].size(); ++i) {
            column[i] = false;
        }
        for (int i = 0; i < matrix.size(); ++i) {
            for (int j = 0; j < matrix[0].size(); ++j) {
                if (!matrix[i][j]) {
                    row[i] = true;
                    column[j] = true;
                }
            }
        }
        for (int i = 0; i < matrix.size(); ++i) {
            if (row[i]) {
                for (int j = 0; j < matrix[0].size(); ++j) {
                    matrix[i][j] = 0;
                }
            }
        }
        for (int j = 0; j < matrix[0].size(); ++j) {
            if (column[j]) {
                for (int i = 0; i < matrix.size(); ++i) {
                    matrix[i][j] = 0;
                }
            }
        }
    }
};

int main() {
    Solution sl;
    vector<vector<int>> m = {{0, 1}};
    sl.setZeroes(m);
    for (int i = 0; i < m.size(); ++i) {
        for (int j = 0; j < m[0].size(); ++j) {
            cout << m[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}